package com.online.yiqi.controller;

import com.online.yiqi.mapper.UserMapper;
import com.online.yiqi.model.UserPo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping(value="/${spring.application.name}/v1/subscribe")
@Api(value="SubscribeContorller",description = "预约类接口")
public class SubscribeContorller {

    static final List<UserPo> userCache = new ArrayList<>();
    static{
        userCache.add(new UserPo(1,"周志臻",24));
        userCache.add(new UserPo(2,"周志超",24));
    }

    @Resource
    private UserMapper userMapper;

    @ApiOperation(value="获取用户列表")
    @PostMapping("/getUserInfo")
    public List<UserPo> getUserInfo() {
        return userCache;
        //return userMapper.findUserInfo();
    }

    @ApiOperation(value="添加用户")
    @PostMapping("/addUserInfo")
    public String getUserInfo(@RequestBody UserPo user) {
//        int count = userMapper.addUser(user);
//        return count==1?"success":"error";
        userCache.add(user);
        return "success";
    }


}
